<?php
/**
 * Created by PhpStorm.
 * User: 跳梁
 * Date: 2015/10/29
 * Time: 15:19
 */
header("Content-type: text/html; charset=utf-8");
include_once('simple_html_dom.php');
class QinyuanAction extends Action{
    public function getExpress($name,$Express,$orderNum){
        $html = new simple_html_dom();
        $html->load_file("http://www.chinz56.co.nz/cgi-bin/GInfo.dll?EmmisTrack&w=chinz56&cno=$orderNum");
        if(!$html->find("#HeaderNum",0)){
            return;
        }
        $order = $html->find("#HeaderNum",0)->find("text",-1);
        $result['LogisticCode'] = iconv("GBK", "UTF-8//TRANSLIT", $order);
        $num =  $html->find("#HeaderItem",0)->find("text",-1);
        $result['num'] = iconv("GBK", "UTF-8//TRANSLIT", $num);
        $status =  $html->find("#HeaderState",0)->find("text",-1);
        $result['State'] = iconv("GBK", "UTF-8//TRANSLIT", $status);
        foreach($html->find('#oTHtable tr') as $key=>$element){
            if($key>0){
                $time = $element->first_child ()->find("text",0);
                $content= $element->last_child ()->find("text",0);
                $time = iconv("GBK", "UTF-8//TRANSLIT", $time);
                $content = iconv("GBK", "UTF-8//TRANSLIT", $content);
                $arr[$key-1]['AcceptTime']=$time;
                $arr[$key-1]['AcceptStation']=$content;
            }
        }
        $result['name']="快递方式：秦远物流";
        $result["Traces"]=array_reverse($arr);
        return $result;
    }

}